package org.jsola.hr.helper;

import org.jsola.common.ClassKit;
import org.jsola.common.SafeKit;
import org.jsola.hr.dto.TransferAccountsDetailAddDTO;
import org.jsola.hr.dto.TransferAccountsDetailUpdateDTO;
import org.jsola.hr.entity.TransferAccountsDetailDO;
import org.jsola.hr.query.TransferAccountsDetailQuery;
import org.jsola.hr.service.ITransferAccountsDetailService;
import org.jsola.hr.vo.TransferAccountsDetailVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

import static org.jsola.hr.core.AbstractTest.SITE_ID;



/**
 * 转账明细
 *
 * @author zhr
 */
@Component
public class TransferAccountsDetailTestHelper extends BaseTestHelper {
    
    @Autowired
    private ITransferAccountsDetailService transferAccountsDetailService;

    /**
     * 生成add测试数据
     * @return TransferAccountsDetailAddDTO
     */
    public TransferAccountsDetailAddDTO getTransferAccountsDetailAddDTO(){
        TransferAccountsDetailAddDTO transferAccountsDetailAddDTO = new TransferAccountsDetailAddDTO();
        transferAccountsDetailAddDTO.setCompanyId(getRandomValue("varchar",32));
        transferAccountsDetailAddDTO.setSubjectId(getRandomValue("varchar",32));
        transferAccountsDetailAddDTO.setPeopleId(getRandomValue("varchar",32));
        transferAccountsDetailAddDTO.setName(getRandomValue("varchar",256));
        transferAccountsDetailAddDTO.setPhone(getRandomValue("varchar",20));
        transferAccountsDetailAddDTO.setIdCard(getRandomValue("varchar",20));
        transferAccountsDetailAddDTO.setBankId(getRandomValue("varchar",50));
        transferAccountsDetailAddDTO.setBankName(getRandomValue("varchar",64));
        transferAccountsDetailAddDTO.setType(SafeKit.getInteger(getRandomValue("int",4)));
        transferAccountsDetailAddDTO.setIdentity(getRandomValue("varchar",100));
        transferAccountsDetailAddDTO.setIdentityBinding(SafeKit.getBoolean(getRandomValue("tinyint",1)));
        transferAccountsDetailAddDTO.setIsPingAnBank(SafeKit.getBoolean(getRandomValue("tinyint",1)));
        transferAccountsDetailAddDTO.setIsOthArea(SafeKit.getBoolean(getRandomValue("tinyint",1)));
        transferAccountsDetailAddDTO.setMoney(SafeKit.getBigDecimal(getRandomValue("decimal",11)));
        transferAccountsDetailAddDTO.setOrderTitle(getRandomValue("varchar",64));
        transferAccountsDetailAddDTO.setRemark(getRandomValue("varchar",256));
        transferAccountsDetailAddDTO.setBatchId(getRandomValue("varchar",32));
        transferAccountsDetailAddDTO.setThirdpartyDetailId(getRandomValue("varchar",100));
        transferAccountsDetailAddDTO.setThirdPartyInteriorDetailId(getRandomValue("varchar",200));
        transferAccountsDetailAddDTO.setSubjectStatus(SafeKit.getInteger(getRandomValue("int",4)));
        transferAccountsDetailAddDTO.setPayStatus(SafeKit.getInteger(getRandomValue("int",4)));
        transferAccountsDetailAddDTO.setPayTime((Date)ClassKit.getObjectValue(getRandomValue("datetime",0),"java.util.Date"));
        transferAccountsDetailAddDTO.setFee(SafeKit.getBigDecimal(getRandomValue("decimal",11)));
        transferAccountsDetailAddDTO.setFailCause(getRandomValue("varchar",200));
        transferAccountsDetailAddDTO.setIsDispose(SafeKit.getBoolean(getRandomValue("tinyint",1)));
        return transferAccountsDetailAddDTO;
    }


    /**
     * 生成update测试数据
     * @return TransferAccountsDetailUpdateDTO
     */
    public TransferAccountsDetailUpdateDTO getTransferAccountsDetailUpdateDTO(TransferAccountsDetailVO transferAccountsDetailVO){
        return transferAccountsDetailService.selectDOById(transferAccountsDetailVO.getId(), SITE_ID).to(TransferAccountsDetailUpdateDTO.class);
    }

    /**
     * 生成查询数据
     * @return TransferAccountsDetailQuery
     */
    public TransferAccountsDetailQuery getTransferAccountsDetailQuery() {
        TransferAccountsDetailQuery transferAccountsDetailQuery = new TransferAccountsDetailQuery();
        List<TransferAccountsDetailDO> transferAccountsDetailDOList = transferAccountsDetailService.list(new TransferAccountsDetailDO(),SITE_ID);
        if (!CollectionUtils.isEmpty(transferAccountsDetailDOList)) {
            TransferAccountsDetailDO transferAccountsDetailDO = transferAccountsDetailDOList.get(0);
            transferAccountsDetailQuery = transferAccountsDetailDO.to(TransferAccountsDetailQuery.class);
        }
        return transferAccountsDetailQuery;
    }

    /**
     * 保存示例
     * @return TransferAccountsDetailVO
     */
    public TransferAccountsDetailVO saveTransferAccountsDetailExample(){
        TransferAccountsDetailAddDTO addDTO = this.getTransferAccountsDetailAddDTO();
        TransferAccountsDetailVO transferAccountsDetailVO = transferAccountsDetailService.save(addDTO,buildTokenUser());
        return transferAccountsDetailVO;
    }


}

